package com.shy.task.quartz.core;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.shy.task.service.TaskEntityService;

/**
 * quartz job 初始化
 *
 * @author shanhanyu
 * @date 2018/9/10 - 17:11
 */
@Component
public class QuartzJobLoader implements InitializingBean {

	@Autowired
	private TaskEntityService taskEntityService;
	@Autowired
	private QuartzService quartzService;

	@Override
	public void afterPropertiesSet() {
          taskEntityService .findAll() .forEach(job ->
          quartzService.addQuartzJob(job));
	}
}
